package com.data;

import java.util.Scanner;
public class Work_1 {
    public static void main(String[] args) {
        A a = new A();
        a.B();
    }
}

class A{
    public void menu(){
        String menu="商品名\t\t\t商品价格";
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入商品名称");
        String str=scanner.next();
        System.out.println("请输入商品价格");
        String price =scanner.next();
        //输出怎么解决?
        //先解决price逗号问题
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer=stringBuffer.append(price);
        int count=Integer.parseInt(price)/3;
        //得到逗号个数
    }

    public void B(){
        String menu="商品名\t\t\t商品价格\n";
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入商品名称");
        String str=scanner.next();
        System.out.println("请输入商品价格");
        String price =scanner.next();//必须输入浮点数
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer=stringBuffer.append(price);
        int index=stringBuffer.indexOf(".");
        for(int i=index-3;i>0;i-=3){
            stringBuffer.insert(i,",");
        }
        System.out.println(menu+str+"\t\t"+stringBuffer);
    }
}
